﻿Imports DTO
Imports DAO.DataProvider
Imports System.Data
Imports System.Data.OleDb
Public Class ThamSoDAO
    'xu ly lay tien kham
    Public Function tienkhambenhnhan() As Long
        Dim DTP As New DataProvider()
        Dim cnn As New OleDbConnection()
        cnn = DTP.ConnectDB()
        cnn.Open()
        Dim cmd As OleDbCommand = New OleDbCommand()
        cmd.Connection = cnn
        cmd.CommandText = "select TienKham from THAMSO "
        Dim temp As Integer
        temp = cmd.ExecuteScalar()
        Return temp
    End Function
    'xu ly lay so luong benh nhan toi da trong ngay tu bang tham so
    Public Function SoLuong() As Integer
        Dim DTP As New DataProvider()
        Dim cnn As New OleDbConnection()
        cnn = DTP.ConnectDB()
        cnn.Open()
        Dim cmd As OleDbCommand = New OleDbCommand()
        cmd.Connection = cnn
        cmd.CommandText = "select KhamToiDa from THAMSO "
        Dim temp As Integer
        temp = cmd.ExecuteScalar()
        Return temp
    End Function
    'xu ly sua~ so luong kham toi da trong ngay
    Public Function UPDATE_KHAMTOIDA(ByVal TS As ThamSoDTO) As Integer
        Try
            Dim DTP As New DataProvider()
            'tao ket noi
            Dim _cnn As OleDbConnection = DTP.ConnectDB()
            'mo ket noi
            _cnn.Open()
            'tao cau lenh command
            'SqlCommand(cmd = New SqlCommand(query, cnn))
            Dim cmd As OleDbCommand = New OleDbCommand()
            cmd.Connection = _cnn
            cmd.CommandText = " update THAMSO set (KhamToiDa=@ktd) "
            Dim para As OleDbParameter = cmd.Parameters.Add("@ktd", OleDbType.BigInt)
            para.Value = TS.KhamToiDa

            'goi thuc thi cau lenh
            Dim flag As Integer
            flag = cmd.ExecuteNonQuery()
            _cnn.Close()
            If (flag > 0) Then
                Return 1
            Else
                Return 0
            End If
            'Return flag
            'MessageBox.Show("a" + NV.MaHocSinh)
        Catch ex As Exception
            ex.Message.ToString()
        End Try

    End Function
    'xu ly sua~ TIEN KHAM
    Public Function UPDATE_TIENKHAM(ByVal TS As ThamSoDTO) As Integer

        Try
            Dim DTP As New DataProvider()
            'tao ket noi
            Dim _cnn As OleDbConnection = DTP.ConnectDB()
            'mo ket noi
            _cnn.Open()
            'tao cau lenh command
            'SqlCommand(cmd = New SqlCommand(query, cnn))


            Dim str As String = "update THAMSO set (TienKham=@tk) "
            Dim cmd As New OleDbCommand(str, _cnn)
            Dim para As OleDbParameter = cmd.Parameters.Add("@tk", OleDbType.BigInt)
            para.Value = TS.TienKham

            'goi thuc thi cau lenh
            Dim flag As Integer
            flag = cmd.ExecuteNonQuery()
            _cnn.Close()
            If (flag > 0) Then
                Return 1
            Else
                Return 0
            End If
            'MessageBox.Show("a" + NV.MaHocSinh)
        Catch ex As Exception
            ex.Message.ToString()
        End Try

    End Function
End Class
